package net.exoweb.animate.graphics
{
    import flash.display.BitmapData;

    import net.exoweb.animate.graphics.GPixel;
    import net.exoweb.animate.graphics.GShape;

    public class GPixelMap extends GShape
    {
        public var pixels:Array;

        public function GPixelMap(bitmapData:BitmapData, bm:String="normal")
        {
            super(0, bm);
            pixels = new Array();
            for(var i:int=0; i<bitmapData.width; i++)
            {
                var a:Array = new Array;
                for(var j:int=0; j<bitmapData.height; j++)
                {
                    var color:uint = bitmapData.getPixel32(i, j);
                    var pixel:GPixel = new GPixel(color);
                    var alp:Number = color >> 24;
                    if(alp != 0)
                    {
                        pixel.x = i;
                        pixel.y = j;
                        pixel.alpha = 0;
                        pixel.display();
                        a.push(pixel);
                        addChild(pixel);
                    }
                    else
                    {
                        pixel.x = i;
                        pixel.y = j;
                        pixel.color = 0;
                        pixel.alpha = 1;
                        a.push(pixel);
                    }
                }
                pixels.push(a);
            }
        }
    }
}
